package com.chinacache.maint.workorder.service;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.transaction.annotation.Transactional;

import com.chinacache.maint.commons.orm.hibernate.Page;
import com.chinacache.maint.commons.orm.hibernate.SimpleHibernateDao;
import com.chinacache.maint.workorder.entity.FieldClassToField;

@Transactional
public class FieldClassToFieldManager {
	private SimpleHibernateDao<FieldClassToField, Integer> fieldDao;

	@Required
	public void setSessionFactory(SessionFactory sessionFactory) {
		fieldDao = new SimpleHibernateDao<FieldClassToField, Integer>(
				sessionFactory, FieldClassToField.class);
	}

	@Transactional(readOnly = true)
	public FieldClassToField getFieldClassToField(Integer id) {
		return fieldDao.findById(id);
	}

	@Transactional(readOnly = true)
	public Page<FieldClassToField> getAllFieldClassToField(
			Page<FieldClassToField> page) {
		return fieldDao.findAll(page);
	}

	public void saveFieldClassToField(FieldClassToField field) {
		fieldDao.save(field);
	}

	public void deleteFieldClassToField(Integer id) {
		FieldClassToField field = fieldDao.findById(id);
		fieldDao.delete(field);
	}

	public void updateFieldClassToField(FieldClassToField field) {
		fieldDao.update(field);
	}

	@Transactional(readOnly = true)
	public List<FieldClassToField> getAllFieldClassToField() {
		return fieldDao.findAll();
	}
}
